{template 'common/header'}
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<div class="panel panel-default">
    <div class="panel-heading">
        <h3 class="panel-title">
            {$xtitle}
        </h3>
    </div>
    <div class="panel-body">
        {template 'Web/menu'}
        <form class="form-horizontal" role="form" method="post" action="{url 'site/entry/announcement',array('m'=>$_GPC['m'],'op'=>'savemodel','version_id'=>$_GPC['version_id'])}" name="submit" style="padding: 20px 0;">
            <div class="form-group">
                <label for="name" class="col-sm-2 control-label">名称</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="name" id="name" value="{$list['name']}">
                    <input type="hidden" name="id" value="{$list['id']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">状态</label>
                <div class="col-sm-8">
                    {if $list['content']['status']==1}
                    <input type="checkbox" checked class="js-switch" value="1" name="status">
                    {else}
                    <input type="checkbox" class="js-switch" name="status" value="1">
                    {/if}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">图片</label>
                <div class="col-sm-8">
                    {php echo tpl_form_field_image('bimg',$list['content']['bimg']);}
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">链接</label>
                <div class="col-sm-8">
                    <div class="input-group ">
                        <input type="text" class="form-control"  name="link" value="{$list['content']['link']}">
                        <span class="input-group-btn">
                            <button class="btn btn-default link" type="button" data-toggle="modal" data-target="#sort_link">选择链接</button>
                        </span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">频次</label>
                <div class="col-sm-8">
                    <label class="radio inline" style="width:100px;">
                        <input type="radio" class="ui-radio" name="type" id="type1" value="1" {if $list['content']['type']==1}checked{/if}>首次登录弹出
                    </label>
                    <label class="radio inline" style="width:100px;">
                        <input type="radio" class="ui-radio" name="type" id="type2" value="2" {if $list['content']['type']==2}checked{/if}>每天弹出一次
                    </label>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="button" name="submit" class="btn btn-default" value="提交">
                </div>
            </div>
        </form>
    </div>
</div>
<div class="modal fade" id="sort_link"><div class="modal-dialog">
    <style>
        #sort_link .modal-body {padding: 10px 15px;}
        #sort_link .tab-pane {margin-top: 5px; min-height: 400px; max-height: 400px; overflow-y: auto;}
        #sort_tab{margin-bottom: 10px;}
    </style>
    <div class="modal-content">
        <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button">×</button>
            <h4 class="modal-title">链接</h4>
        </div>
        <div class="modal-body">
            <ul class="nav nav-tabs" id="selectUrlTab">
                <li role="presentation" class="active"><a href="#sut_shop">页面</a></li>
                <li role="presentation"><a href="#sut_time">文章</a></li>
            </ul>
            <div class="tab-content">
                <div class="tab-pane active" id="sut_shop">
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../news/news" class="btn btn-default btn-sm" title="新闻动态">新闻动态</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../contact/contact" class="btn btn-default btn-sm" title="联系我们">联系我们</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../teacher/teacher" class="btn btn-default btn-sm" title="名师简介">名师简介</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../service/index" class="btn btn-default btn-sm" title="所有课程">所有课程</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../sign/sign" class="btn btn-default btn-sm" title="报名缴费">报名缴费</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../store/index" class="btn btn-default btn-sm" title="分校查询">分校查询</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../user/user" class="btn btn-default btn-sm" title="个人中心">个人中心</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../video/video" class="btn btn-default btn-sm" title="视频">视频</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../active/list" class="btn btn-default btn-sm" title="优惠活动">优惠活动</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../coupon/coupon" class="btn btn-default btn-sm" title="优惠券">优惠券</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../cut/list" class="btn btn-default btn-sm" title="砍价">砍价</nav>
                    <nav style="margin-bottom: 5px;" data-dismiss="modal" data-href="../mall/mall" class="btn btn-default btn-sm" title="砍价">商城</nav>
                </div>
                <div class="tab-pane" id="sut_time">
                    <iframe width="100%" height="395" frameborder="no" border="0" scrolling="no" allowtransparency="yes" src="{url 'site/entry/Banner',array('m'=>$_GPC['m'],'op'=>'article')}"></iframe>
                </div>
            </div>
        </div>
        <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" id="sort_close" type="button">关闭</button>
        </div>
        <script>
            var sort_objc='';
            $(function(){
                $("#sort_link").find('#selectUrlTab a').click(function(e) {
                    $('#tab').val($(this).attr('href'));
                    e.preventDefault();
                    $(this).tab('show');
                });
                $(".sort_customize").on('click','.sort_link',function(){
                    var id=$(this).attr("data-id");
                    if(id==2){
                        $("#sort_link").find("#sort_tab li").eq(1).hide();
                    }else{
                        $("#sort_link").find("#sort_tab li").eq(1).show();
                    }
                    sort_objc=this;
                });
                $("#sut_shop").find("nav").click(function(){
                    $(objc).parent().prev().val($(this).attr("data-href"));
                });
            });
        </script>
    </div>
</div></div>
<script>
    var objc="";
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function(){
            $("body").on("click",'.link',function(){
                objc=this;
            });
            $("input[name='submit']").click(function(){
                var data=$(".form-horizontal").serialize();
                $.ajax({
                    type:"post",
                    url:"{url 'site/entry/'.$_GPC['do'],array('m'=>$_GPC['m'],'op'=>'saveopen_ad','version_id'=>$_GPC['version_id'])}",
                    data:data,
                    dataType:'json',
                    success:function(res){
                        if(res.status==1){
                            swal('操作成功!', '操作成功!', 'success');
                        }else{
                            swal('操作失败!', '操作失败!', 'error');
                        }
                    }
                })
            });
        })
    })
</script>
{template 'common/footer'}